﻿using Elike.Toolkit.ControlsErgodic.Windows;
using shopsoft.business.SystemConfig;
using shopsoft.models.ClassBase;
using shopsoft.models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace shopsoft.main.AppCommon
{
    /// <summary>
    /// 参数配置
    /// </summary>
    public static class ParameterConfig
    {
        #region Private Attribute

        /// <summary>
        ///会员等级
        /// </summary>
        private static List<MemberGrade> memberGrades = new List<MemberGrade>() { new MemberGrade() { Name = string.Empty } };
        /// <summary>
        ///消费类型
        /// </summary>
        private static List<DataRecord> offTypes = new List<DataRecord> { new DataRecord() { Name = string.Empty } };
        /// <summary>
        ///会员状态
        /// </summary>
        private static List<DataRecord> memberStatus = new List<DataRecord> { new DataRecord() { Name = string.Empty } };
        /// <summary>
        ///会员性别
        /// </summary>
        private static List<DataRecord> memberSex = new List<DataRecord> { new DataRecord() { Name = string.Empty } };
        /// <summary>
        ///会员证件类型
        /// </summary>
        private static List<DataRecord> memberIdentityTypes = new List<DataRecord> { new DataRecord() { Name = string.Empty } };

        #endregion Private Attribute

        #region Public Method

        /// <summary>
        /// 会员等级
        /// </summary>
        public static List<MemberGrade> GetMemberGrades()
        {
            //第一次获取
            if (memberGrades.Count == 1)
            {
                try
                {
                    memberGrades.AddRange(new SCMember().GetMemberGrades(new MemberGrade() { CurrentOperator = Program.CurrentUser, DelFlag = false }));
                }
                catch (Exception ex)
                {
                    MsgBox.Information("提示", ex.Message);
                }
            }
            return memberGrades;
        }

        /// <summary>
        /// 优惠方式
        /// </summary>
        /// <returns></returns>
        public static List<DataRecord> GetOffTypes()
        {
            //第一次获取
            if (offTypes.Count == 1)
            {
                var tmpOffTypes = new List<DataRecord>() { new DataRecord() { ID = 0, Name = "不优惠" }, new DataRecord() { ID = 1, Name = "消费优惠" }};

                offTypes.AddRange(tmpOffTypes);
            }

            return offTypes;
        }

        /// <summary>
        /// 会员状态
        /// </summary>
        /// <returns></returns>
        public static List<DataRecord> GetMemberStatus()
        {
            //第一次获取
            if (memberStatus.Count == 1)
            {
                var tmpMemberStatus = new List<DataRecord>() { new DataRecord() { ID = 0, Name = "可用" }, new DataRecord() { ID = 1, Name = "不可用" } };

                memberStatus.AddRange(tmpMemberStatus);
            }

            return memberStatus;
        }

        /// <summary>
        /// 会员性别
        /// </summary>
        /// <returns></returns>
        public static List<DataRecord> GetMemberSex()
        {
            //第一次获取
            if (memberSex.Count == 1)
            {
                var tmpMemberSex = new List<DataRecord>() { new DataRecord() { ID = 0, Name = "男" }, new DataRecord() { ID = 1, Name = "女" } };

                memberSex.AddRange(tmpMemberSex);
            }

            return memberSex;
        }

        /// <summary>
        /// 会员证件类型
        /// </summary>
        /// <returns></returns>
        public static List<DataRecord> GetMemberIdentityTypes()
        {
            //第一次获取
            if (memberIdentityTypes.Count == 1)
            {
                var tmpMemberIdentityTypes = new List<DataRecord>() { 
                        new DataRecord() { ID = 1, Name = "身份证" }, 
                        new DataRecord() { ID = 2, Name = "军官证" },
                        new DataRecord() { ID = 3, Name = "学生证" }};

                memberIdentityTypes.AddRange(tmpMemberIdentityTypes);
            }

            return memberIdentityTypes;
        }

        #endregion Public Method
    }
}
